﻿<html>
<head>
    <title></title>
    <div id="themefile"></div>
    <style>
        @import "this://app/images/public.css";
        @import "images/form.css";
        html, body {width: *;height: *;overflow: hidden;margin: 0;padding: 0;background: color(center-background-color);color: color(general-text-color)}
        input,select{width:150dip}
        .wrapper {width: *;padding: 8 dip;flow:horizontal-flow;}
        .inner {display:block;width:*}
    </style>
</head>
<body>
<div class="wrapper">

    <div class="inner">
        <table>
            <tr>
                <td>{{BaseType}}：</td>
                <td><select id="type" editable></select></td>
            </tr>
            <tr>
                <td>{{BaseYear}}：</td>
                <td><input type="text" id="year" value=""></td>
            </tr>
            <tr>
                <td>{{BaseProducer}}：</td>
                <td><select id="producer" editable></select></td>
            </tr>
            <tr>
                <td>{{BasePublisher}}：</td>
                <td><select id="publisher" editable></select></td>
            </tr>
            <tr>
                <td>{{BaseCountry}}：</td>
                <td><select id="country" editable></select></td>
            </tr>
            <tr>
                <td>{{BaseVersion}}：</td>
                <td><select id="version" editable></select></td>
            </tr>
            <tr>
                <td>{{BaseTranslate}}：</td>
                <td><input type="text" id="translate"></td>
            </tr>
            <tr>
                <td>{{Score}}</td>
                <td><select id="score" editable>
                <option value='0'>0</option>
                    <option value='0.5'>0.5</option>
                    <option value='1.0'>1.0</option>
                    <option value='1.5'>1.5</option>
                    <option value='2.0'>2.0</option>
                    <option value='2.5'>2.5</option>
                    <option value='3.0'>3.0</option>
                    <option value='3.5'>3.5</option>
                    <option value='4.0'>4.0</option>
                    <option value='4.5'>4.5</option>
                    <option value='5.0'>5.0</option>
                </select></td>
            </tr>
        </table>
    </div>

    <div class="inner">
        <table>
            <tr>
                <td>{{BaseName}}：</td>
                <td><input type="text" id="name" value=""></td>
            </tr>
            <tr>
                <td>{{BaseNameEN}}：</td>
                <td><input type="text" id="name_en" value=""></td>
            </tr>
            <tr>
                <td>{{BaseNameJP}}：</td>
                <td><input type="text" id="name_jp" value=""></td>
            </tr>
            
            <tr>
                <td>{{BaseOther}}：</td>
                <td><input type="text" id="other_a">
                </td>
            </tr>
            <tr>
                <td></td>
                <td><input type="text" id="other_b"></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="text" id="other_c"></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="text" id="other_d"></td>
            </tr>
        </table>
    </div>

</div>
<div class="form_bottom">
    <button class="cancel" id="close-dialog">{{Cancel}}</button>
    <button class="ok" id="submit">{{Confirm}}</button>
</div>

<script type="text/tiscript">
include ROOTPATH + "js/utils.js";

view.root.on("ready", function(){
    //初始化主题
    initUiTheme();
    
    //渲染语言
    createLang();
    view.windowCaption = CONF.Lang.EditBaseInfo;
    
    //填充列表
    var typeList = JSON.parse(mainView.GetRombaseEnumList("type"));
    var typeDom = "";
    for(var obj in typeList) {
        typeDom += "<option value='"+ obj +"'>"+obj+"</option>";
    }
    $(#type).options.html = typeDom;

    var publisherList = JSON.parse(mainView.GetRombaseEnumList("publisher"));
    var publisherDom = "";
    for(var obj in publisherList) {
        publisherDom += "<option value='"+ obj +"'>"+obj+"</option>";
    }
    $(#publisher).options.html = publisherDom;

    var producerList = JSON.parse(mainView.GetRombaseEnumList("producer"));
    var producerDom = "";
    for(var obj in producerList) {
        producerDom += "<option value='"+ obj +"'>"+obj+"</option>";
    }
    $(#producer).options.html = producerDom;

    var countryList = JSON.parse(mainView.GetRombaseEnumList("country"));
    var countryDom = "";
    for(var obj in countryList) {
        countryDom += "<option value='"+ obj +"'>"+obj+"</option>";
    }
    $(#country).options.html = countryDom;

    var versionList = JSON.parse(mainView.GetRombaseEnumList("version"));
    var versionDom = "";
    for(var obj in versionList) {
        versionDom += "<option value='"+ obj +"'>"+obj+"</option>";
    }
    $(#version).options.html  = versionDom;

    //填充值
    var getjson = mainView.GetRomBase(view.parameters.id);
    if(getjson != undefined){
        var info = JSON.parse(getjson);
        if(info.Name != undefined && info.Name != ""){$(#name).value = info.Name;}
        if(info.Type != undefined && info.Type != ""){$(#type).value = info.Type;}
        if(info.Year != undefined && info.Year != ""){$(#year).value = info.Year;}
        if(info.Publisher != undefined && info.Publisher != ""){$(#publisher).value = info.Publisher;}
        if(info.Producer != undefined && info.Producer != ""){$(#producer).value = info.Producer;}
        if(info.Country != undefined && info.Country != ""){$(#country).value = info.Country;}
        if(info.Translate != undefined && info.Translate != ""){$(#translate).value = info.Translate;}
        if(info.Version != undefined && info.Version != ""){$(#version).value = info.Version;}
        if(info.Score != undefined && info.Score != ""){$(#score).value = info.Score;}

        if(info.NameEN != undefined && info.NameEN != ""){$(#name_en).value = info.NameEN;}
        if(info.NameJP != undefined && info.NameJP != ""){$(#name_jp).value = info.NameJP;}
        if(info.OtherA != undefined && info.OtherA != ""){$(#other_a).value = info.OtherA;}
        if(info.OtherB != undefined && info.OtherB != ""){$(#other_b).value = info.OtherB;}
        if(info.OtherC != undefined && info.OtherC != ""){$(#other_c).value = info.OtherC;}
        if(info.OtherD != undefined && info.OtherD != ""){$(#other_d).value = info.OtherD;}

    }
    
});

event click $(#submit){
    var year = "";
    if($(#year).value != "" && $(#year).value != undefined){
         year = $(#year).value.toString();
    }else{
         year = "";
    }
    var data = {
        id:view.parameters.id;
        name:$(#name).value,
        year:year,
        type:$(#type).value,
        publisher:$(#publisher).value,
        producer:$(#producer).value,
        country:$(#country).value,
        translate:$(#translate).value,
        version:$(#version).value,
        score:$(#score).value,
        name_en:$(#name_en).value,
        name_jp:$(#name_jp).value,
        other_a:$(#other_a).value,
        other_b:$(#other_b).value,
        other_c:$(#other_c).value,
        other_d:$(#other_d).value,

    }
    var result = mainView.SetRomBase(JSON.stringify(data));
    view.close(result);
}

event click $(#close-dialog){
    view.close();
}



</script>

</body>
</html>